/**
 * 
 */
package view;

import java.util.Random;

import javax.swing.JFrame;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;

/**
 * This class loads the GUI for the Compose New Mail Window.
 * @author Farzana Alam (farzana22@gmail.com)
 * @since May 2013
 *
 */
@SuppressWarnings("serial")
public class ComposeMailView extends JFrame {
	
	/**
	 * This field refers to the {@link ComposeMailMainMenu} instance.
	 */
	private ComposeMailMainMenu mainMenu;	
	
	/**
	 * This field contains the {@link EmailEditorPanel} instance.
	 */
	private EmailEditorPanel emailEditorPanel;
	
	/**
	 * This is the main container for the {@link JPanel}s.
	 */
	private JPanel mainContainer;
	
	/**
	 * This holds the Subject field text.
	 */
	private String subject = "(no subject)";	
	
	/**
	 * Constructs a customized {@link JFrame}.
	 */
	public ComposeMailView() {
		
		// Basic UI settings
		setTitle("Compose New Mail " + subject);
		setSize(400, 350);
		Random random = new Random();
		setLocation(random.nextInt(500), random.nextInt(500));
		setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);		
		
		createPanels();
		
		this.setJMenuBar(mainMenu);
		this.add(mainContainer);
		this.setVisible(true);
	}
	
	/**
	 * This is the Facade for initializing all the panels and the containers.
	 */
	private void createPanels() {

		// Initializing child components
		mainMenu = new ComposeMailMainMenu();		
		mainContainer = new JPanel(new MigLayout("fillx"));
				
		// Initializing child panels inside the main panel
		emailEditorPanel = new EmailEditorPanel(new MigLayout("fillx"));		
				
		// Add child Panels to the main Panel
		mainContainer.add(emailEditorPanel, "growx, wrap");
	}
		
	/**
	 * Getter for emailEditorPanel field.
	 * @return {@link EmailEditorPanel}
	 */
	public EmailEditorPanel getEmailEditorPanel() {
		return emailEditorPanel;
	}
	
	/**
	 * Getter for mainMenu field.
	 * @return {@link ComposeMailMainMenu}
	 */
	public ComposeMailMainMenu getMainMenu() {
		return mainMenu;
	}

}
